package com.itshizhan.viewpager2demo

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import kotlinx.android.synthetic.main.fragment_slide_page.*


class SlidePageFragment():Fragment() {
    companion object {
        const val ARG_POSITION = "position"
        fun getInstance(position: Int): Fragment {
            val slidePageFragment = SlidePageFragment()
            val bundle = Bundle()
            bundle.putInt(ARG_POSITION, position)
            slidePageFragment.arguments = bundle
            return slidePageFragment
        }
    }

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        return  inflater.inflate(R.layout.fragment_slide_page, container, false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        val position = requireArguments().getInt(ARG_POSITION)
        fragmentTv.setText(SlideAdapter.datas[position])
    }
}